import static org.junit.Assert.*;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

/**
 * 
 */

/**
 * @author Leena
 *
 */
public class VendingMachineItemTest {
	VendingMachineItem vmi1;
	VendingMachineItem vmi2;
	VendingMachineItem vmi3;

	/**
	 * @throws java.lang.Exception
	 */
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	/**
	 * @throws java.lang.Exception
	 */
	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
		vmi1 = new VendingMachineItem("Cookie", 1.15);
		vmi2 = new VendingMachineItem("", 1);//vending machine item  with name=""
	}

	
	@Test
	public void testVendingMachineItem(){	
		assertEquals("Cookie", vmi1.getName()); //test that inserted name is the same as the  name of vendingMachineItem
		assertEquals(1.15 , vmi1.getPrice(), 0); //test that inserted price of double type is the same as the  price of the vendingMachineItem
		assertEquals("",vmi2.getName()); //test if program works when name is "";
		assertEquals(1, vmi2.getPrice(), 0);//test that inserted price of int type is the same as the price of the vendingMachineItem
	}
	
	@Test (expected = VendingMachineException.class)
	public void testVendingMachineItemException(){
		vmi3 = new VendingMachineItem("coke", -1);  //test if program go through exception when a negative number is inserted as price parameter
	}
	/**
	 * @throws java.lang.Exception
	 */
	@After
	public void tearDown() throws Exception {
	}

	/**
	 * Test method for {@link VendingMachineItem#getName()}.
	 */
	@Test
	public void testGetName() {
		assertEquals("Cookie", vmi1.getName()); //test if getName() returns correct name of item
		assertEquals("",vmi2.getName()); 
	}

	/**
	 * Test method for {@link VendingMachineItem#getPrice()}.
	 */
	@Test
	public void testGetPrice() {
		assertEquals(1.15 , vmi1.getPrice(), 0); //test if getPrice() returns correct price of item
		assertEquals(1, vmi2.getPrice(), 0);
	}

}
